package com.joysuch.wwyt.bp.entity;

import com.joysuch.wwyt.core.support.AutoSetCommonFieldListener;
import lombok.Data;
import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder;
import org.hibernate.annotations.SQLDelete;
import org.hibernate.annotations.SQLDeleteAll;
import org.hibernate.annotations.Where;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import javax.persistence.*;
import java.io.Serializable;
import java.time.LocalDate;
import java.time.LocalTime;
import java.util.Date;

import static javax.persistence.GenerationType.IDENTITY;

@EntityListeners({AuditingEntityListener.class, AutoSetCommonFieldListener.class})
@Entity
@Table(name = "wwyt_bp_work_safety_cert_signer")
//@SQLDelete(sql = "update wwyt_bp_work_safety_cert_signer set DELETE_FLAG = '1' where id= ?")
//@SQLDeleteAll(sql = "update wwyt_bp_work_safety_cert_signer set DELETE_FLAG = '1' where id= ?")
//@Where(clause = "DELETE_FLAG = '0'")
@Data
public class BpWorkSafetySigener implements Serializable {

    //id
    @Id
    @GeneratedValue(strategy = IDENTITY)
    @Column(name = "ID", unique = true, nullable = false)
    private Long id;

    //作业证id
    @Column(name = "cert_id")
    private Long certId;

    //作业证类型
    @Column(name = "type")
    private String type;

    @Column(name = "signerJson")
    private String signerJson;
//    //签名人id
//    @Column(name = "user_id")
//    private Long userId;
//
//    //签名日期
//    @Column(name = "date")
//    private Date date;
//
//    //签名图片id
//    @Column(name = "imageId")
//    private Long imageId;

    //签名分类:0危害辨识;1措施确认;2分析;3确认
    @Column(name = "category_id")
    private Integer categoryId;

    //签名人描述
    @Column(name = "content")
    private String content;

    //是否同意 0同意;1不同意;2不涉及
    @Column(name = "yes_or_no")
    private Integer yesOrNo;

    @org.springframework.data.annotation.CreatedBy
    @Column(name = "CREATE_BY")
    private Long createBy;

    @org.springframework.data.annotation.CreatedDate
    @Column(name = "CREATE_TIME")
    private Date createTime;

    @org.springframework.data.annotation.LastModifiedBy
    @Column(name = "UPDATE_BY")
    private Long updateBy;

    @org.springframework.data.annotation.LastModifiedDate
    @Column(name = "UPDATE_TIME")
    private Date updateTime;

//    @Column(name = "deleteFlag")
////    private String deleteFlag;

    @Column(name = "orgCode")
    private String orgCode;

    @Column(name = "tenentId")
    private Long tenentId;

    public int hashCode() {
        return new HashCodeBuilder().append(getId()).toHashCode();
    }

    public boolean equals(Object obj) {
        if (obj instanceof BpWorkSafetySigener == false)
            return false;
        if (this == obj)
            return true;
        BpWorkSafetySigener other = (BpWorkSafetySigener) obj;
        return new EqualsBuilder().append(getId(), other.getId()).isEquals();
    }
}
